package com.gf.forcesystem.mq;

import com.gf.forcesystem.config.CotaskingRabbitmqConfig;
import com.gf.forcesystem.config.ForceRabbitmqConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author gaofei
 * @date 2022/8/21 14:49
 * 兵力信息mq发送
 */
@Component
@Slf4j
public class ForeInfoMqSender implements MessagePostProcessor {
    @Resource
    private RabbitTemplate rabbitTemplate;

    public void send(String msg) {
        // log.info("兵力系统>无人机系统 {}", msg);
        rabbitTemplate.convertAndSend(CotaskingRabbitmqConfig.targetExchangeName,
                CotaskingRabbitmqConfig.targetStateRoutingKey, msg, this);
    }

    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        message.getMessageProperties().setExpiration("5000");
        return message;
    }
}
